package code.main.modle.leve
{
	import com.yy.dataStructure.HashMap;

	/**
	 *等级数据 
	 * @author YY
	 * 
	 */
	public class LevelDm
	{
		public var levelMap:HashMap;//等级hash表
		public function LevelDm()
		{
		}
		
		public function parse(arr:Array):void {
			levelMap = new HashMap();
			var i:int;
			var len:int = arr.length;
			var vo:LevelVo;
			for(i=0; i<len; i++) {
				vo = new LevelVo();
				vo.level = arr[i][0];
				vo.needExp = arr[i][1];
				levelMap.put(vo.level, vo);
			} 
		}
		
		/**
		 *活得经验占等级需要经验的百分比 
		 * @param level
		 * @param exp
		 * @return 
		 * 
		 */
		public function getPercent(level:int, exp:int):Number {
			var vo:LevelVo = levelMap.getValue(level);
			if(vo.level) {
				return exp/vo.needExp;
			}
			return 0;
		}
		
		/**
		 *等级需要的经验 
		 * @param level
		 * @return 
		 * 
		 */
		public function getNeedExp(level:int):int {
			var vo:LevelVo = levelMap.getValue(level);
			return vo.needExp;
		}
	}
}